home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
cat_exe.zip
/
LIFE_2.CAR
< prev
next >
Wrap
Text File
|
1994-11-18
|
2KB
|
83 lines
(* enhanced version of Conveys LIFE program *)
(* cells just died or just born are represented with particular colors
via bit manipulation. *)
RECIPE XYSize = 60;
Zet = 4;
Colors = 4;
CONST dead = %00; (* bit sample 0000 *)
just_died = %01; (* bit sample 0001 *)
just_born = %10; (* bit sample 0010 *)
alive = %11; (* bit sample 0011 *)
(* A *)
(* | *)
(* "alive bit" *)
REF east [1,0];
west [-1,0];
north [0,-1];
south [0,1];
north_ea [1,-1];
north_we [-1,-1];
south_ea [1,1];
south_we [-1,1];
VAR a;
PROC add_second_bit:; (* procedure evaluates second bit of *)
(* neighbors that indicate alive state *)
BEGIN (* and returns sum of found bits *)
RETURN ((east XOR %01) SHR 1) + ((west XOR %01) SHR 1) +
((north XOR %01) SHR 1) + ((south XOR %01) SHR 1) +
((north_ea XOR %01) SHR 1) + ((north_we XOR %01) SHR 1) +
((south_ea XOR %01) SHR 1) + ((south_we XOR %01) SHR 1)
END add_second_bit;
EVENT SetUp;
TubeForm;
PlClipActive;
EVENT E0;
RGBBrush (dead, 0, 0, 0); (* black *)
RGBBrush (just_died, 152, 88, 46); (* brown *)
RGBBrush (just_born, 74, 229, 3); (* light green *)
RGBBrush (alive, 50, 174, 30); (* dark green *)
EVENT E1; (* initialization a *)
PARALLEL DO
a := Random (500);
IF a > 492
THEN Self := alive
ELSE Self := dead
FI;
OD;
ShowPlane;
EVENT E2; (* initialization b *)
PlFillRandom (dead, alive);
ShowPlane;
EVENT E3;
PARALLEL DO
a := add_second_bit;
IF (a = 2) OR (a = 3)
THEN IF (a = 3) AND ((Self = dead) OR (Self = just_died))
THEN Self := just_born;
ELSE Self := alive;
FI;
ELSE IF (Self = alive) OR (Self = just_born)
THEN Self := just_died;
ELSE Self := dead;
FI;
FI;
OD;
ShowPlane;
END.